<template>
  <PCard class="service-enterprise-con" :isCardBorder="true" :shadow="'never'" :isHeadBottomBorder="true" :bodyStyle="{width: '100%'}">
    <div slot="header" class="card-title">
      <h3>企业服务</h3>
      <a-button @click="gotoList" type="primary" style="float: right;" >我的服务({{dataCount}})</a-button>
    </div>
    <ServiceCard :btnEvent="ServiceCardEvent"></ServiceCard>

     <!-- 当前页面公共弹框 -->
    <a-modal v-model="winConfig.visible" :title="winConfig.title" :footer="null" :width="winConfig.width" @cancel="winCancel">
      <component :is="winConfig.componentName" :serviceInfo="serviceInfo"  :coloseEvent="winColosedEvent"></component>
    </a-modal>
  </PCard>
</template>

<script>
import getDataForDB from '@/api/qsbserviceEnterprise'
import ServiceCard from './component/ServiceCard.vue'
import selectEnterList from './component/selectEnterList.vue'
import ChangeRegistrationInfo from './component/ChangeRegistrationInfo.vue'
import ChangeTaxPaymentMode from './component/ChangeTaxPaymentMode.vue'
import EnterpriseCancellation from './component/EnterpriseCancellation.vue'
import OtherValueAddedServices from './component/OtherValueAddedServices.vue'


export default {
  name:'ServiceEnterprise',
  components:{ServiceCard,selectEnterList,ChangeRegistrationInfo,ChangeTaxPaymentMode,EnterpriseCancellation,OtherValueAddedServices},
  data(){
    return {
      dataCount:'--',
      winConfig:{
        title:'',
        visible:false,
        width:1000,
        componentName:'selectEnterList',
      },
      serviceInfo:{
        index:0,
        data:{}
      },
    }
  },
  mounted(){
    this.getDataCount()
  },
  methods:{
    gotoList(){
      this.$router.push({
        path: '/enterprise/serviceEnterprise/ServiceEnterpriseList',
        query: {
          bizId: 'list'
        }
      });
    },
    ServiceCardEvent(item,index,code){
      // console.log('服务申请按钮 ServiceCardEvent ==》',item,index,code);
      this.serviceInfo = {index,data:item,code}
      this.winConfig.width = 1000
      this.winConfig.componentName = 'selectEnterList'
      this.winConfig.visible = true
    },
    winCancel(){
      this.winConfig.componentName = ''
    },
    winColosedEvent(selectDataInfo){
      const {index} = this.serviceInfo
      this.winConfig.width = 1000

      const tempPageList = {
        0:(selectDataInfo)=>{
          const param = {
            bizId:selectDataInfo.id,//指定值或者获取的值
            // serviceInfo:this.serviceInfo, //其他需要传递的参数
            entName: selectDataInfo.entName // '企业名称', // 企业名称
          }
          // console.log('@@@@@@@@@@@@@@@@@===>',param);
          this.$router.push({
            path: '/enterprise/serviceEnterprise/BankAccount',
            query:param
          });
        }, //银行开户   跳转  企业服务-银行开户-0 页面
        1:(selectDataInfo)=>{
          // console.log('########################',selectDataInfo);
          this.serviceInfo = {index,data:selectDataInfo}
          this.winConfig.componentName = 'ChangeRegistrationInfo'
          this.winConfig.visible = true
        }, // 工商注册信息变更  弹框

        2:(selectDataInfo)=>{
          this.serviceInfo = {index,data:selectDataInfo}
          this.winConfig.width = 1000
          this.winConfig.componentName = 'ChangeTaxPaymentMode'
          this.winConfig.visible = true
        }, // 变更纳税模式  弹框
        3:(selectDataInfo)=>{
          this.serviceInfo = {index,data:selectDataInfo}
          this.winConfig.width = 500
          this.winConfig.componentName = 'EnterpriseCancellation'
          this.winConfig.visible = true
        }, // 企业注销  弹框
        4:(selectDataInfo)=>{
          // 其他增值服务 弹框
          this.serviceInfo = {index,data:selectDataInfo}
          this.winConfig.width = 1000
          this.winConfig.componentName = 'OtherValueAddedServices'
          this.winConfig.visible = true
        },
        5:(selectDataInfo)=>{
          // // 注销企业关闭
          // this.winConfig.componentName = ''
          // this.winConfig.visible = false
          // this.$message.info(selectDataInfo.mesg)
        },

        14:(selectDataInfo)=>{
          // 公共关闭窗口  关闭弹框  工商注册信息变更  变更纳税模式  注销企业关闭
          this.winConfig.componentName = ''
          this.winConfig.visible = false
          selectDataInfo.mesg && this.$message.success(selectDataInfo.mesg)
        },
      }
      // console.log('关闭事件 winColosedEvent==>',index,selectDataInfo);
      tempPageList[index](selectDataInfo)
    },
    getDataCount(){
      getDataForDB('企业服务列表-数量').then(res=>{
        if(res.code==200){
          this.dataCount = res.result
        } else {
          this.$message.warning(res.message)
        }
      })
    }
  }

}
</script>

<style lang="less">
.service-enterprise-con{
  .card-title{
    display: flex;
    justify-content: space-between;
    align-items: center;
    //font-size: 28px;
    font-family: PingFangSC-Semibold, PingFang SC;
    color: #333333;
    h3{
      font-size: 20px;
      font-weight: 600;
    }
  }

}
.ant-modal-close-x{
    width: 40px;
    height: 40px;
    line-height: 40px;
  }
</style>
